/*#include<stdio.h>
# define M 10
struct student{
	long xh;
	char xm[20];
	int year;
	int age;
};
void ages(int j,struct student a[])
{
	int i;
	for(i=0;i<M;i++)
	a[i].age=j-a[i].year;
}
void put(struct student a[])
{
	int i;
	for(i=0;i<M;i++)
	{
		if (a[i].age>20)
		{
			printf("%ld,%s,%d,%d\n",a[i].xh,a[i].xm,a[i].year,a[i].age);
		}
	}
}
int main()
{
	struct student a[M];
	int i,j;
	for(i=0;i<M;i++)
	{
		scanf("%ld",&a[i].xh);
		getchar();
		gets(a[i].xm);
		scanf("%d",&a[i].year);
	}
	scanf("%d",&j);
	ages(j,a); 
	put(a);
	return 0;
}*/
#include<stdio.h>
# define M 2
struct student{
	long xh;
	int cj;
};
int fun(struct student *s,int low,int high,struct student *b)
{
	int y=0;
	struct student *p=s;
	struct student *q=b;
	for(p=s;p<s+M;p++)
	{
		if(p->cj>low&&p->cj<high)
		{
			q->xh=p->xh;
			q->cj=p->cj;
			q++;
			y++;
		}
	}
	return y;
}
int main()
{
	struct student a[M];
	struct student b[M];
	int x,y,i,j;
	for(x=0;x<M;x++)
	{
		scanf("%ld",&a[x].xh);
		scanf("%d",&a[x].cj);
	}
	scanf("%d%d",&i,&j);
	y=fun(a,i,j,b);
	for(x=0;x<y;x++)
	{
		printf("%ld,%d",b[x].xh,b[x].cj );
	}
	return 0;
}
